From: George Dunlap Date: Mon, 9 Oct 2017 14:03:53 +0000 (+0200) Subject: fuzz/x86_emulate: actually use cpu_regs input X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~1201 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=581c3e874c300695ddfa8b2a95675a42ebf97301;p=xen.git fuzz/x86_emulate: actually use cpu_regs input Commit c07574b reorganized the way fuzzing was done, explicitly creating a structure that the input data would be copied into. Unfortunately, the cpu register state used by the emulator is on the stack; it's cleared, but data is never copied into it. If we're explicitly setting an entirely new cpu_regs struct for each new input anyway, there's no need to have two copies around anymore; just point to the one in the data structure. Signed-off-by: George Dunlap Reviewed-by: Wei Liu Reviewed-by: Jan Beulich --- diff --git a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c index 105145e9f9..48a879cc88 100644 --- a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c +++ b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c @@ -785,13 +785,12 @@ int LLVMFuzzerInitialize(int *argc, char ***argv) int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size) { - struct cpu_user_regs regs = {}; struct fuzz_state state = { .ops = all_fuzzer_ops, }; struct x86_emulate_ctxt ctxt = { .data = &state, - .regs = ®s, + .regs = &input.regs, .addr_size = 8 * sizeof(void *), .sp_size = 8 * sizeof(void *), };